package com.warmheart.core.rs.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @ClassName: FieldTypeEnum
 * @Description: 查询结果字段类型枚举类
 * @author ZhangJianyang
 * @date 2025-06-16 09:37:02
 *
 */
public enum FieldTypeEnum {

    SINGLE("single", "单字段"), MULTIPLE_FIRST("multipleFirst", "多字段首字段"), MULTIPLE_NEXT("multipleNext", "多字段后续字段"), GROUP(
            "group", "分组字段"), COUNT("count", "数量统计字段"), KEY("key", "KEY字段"), VALUE("value", "VALUE字段");

    private static final Map<String, FieldTypeEnum> map = new HashMap<String, FieldTypeEnum>();

    static {
        for (FieldTypeEnum obj : FieldTypeEnum.values()) {
            map.put(obj.value, obj);
        }
    }

    // 枚举值
    private String value;

    // 描述
    private String desc;

    private FieldTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static FieldTypeEnum fromString(String valueStr, FieldTypeEnum... defaultEnum) {
        FieldTypeEnum obj = map.get(valueStr);
        if (obj == null && defaultEnum != null && defaultEnum.length > 0)
            return defaultEnum[0];
        return obj;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

}
